﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using qiupeng.Public;
using System.IO;

public partial class JiGouManage_JgMain_BZ : Base
{
    Db List = new Db();
    BindDrowDownList list = new BindDrowDownList();
    public string showjg;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["username"] == null)
        {
            base.Response.Write("<script language=javascript>alert('登陆超时！');window.parent.location = '../main_d.aspx'</script>");
        }
        else
        {
            if (!this.Page.IsPostBack)
            {
                this.BindAttribute();
                string sql = "select * from qp_hr_JiGou where id='" + this.List.GetFormatStr(base.Request.QueryString["id"]) + "'";
                OleDbDataReader list = this.List.GetList(sql);
                if (list.Read())
                {
                    this.Name.Text = list["JgName"].ToString();
                }
                list.Close();
            }
            this.DataBindToGridview("order by id desc");
        }

    }
    public void BindAttribute()
    {
        LinkButton1.Attributes["onclick"] = "javascript:return openuser1();";
    }

    public void DataBindToGridview(string Sqlsort)
    {
        string SQL_GetList_xs = "select * from qp_hr_JiGou_GW  where JgNameId='" + Request.QueryString["id"] + "'  " + Sqlsort + "";
        GridView1.DataSource = List.GetGrid_Pages_not(SQL_GetList_xs);
        GridView1.DataBind();

    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            Response.Redirect("JgMain.aspx?id=" + Request.QueryString["id"] + "");
        }
        else
        {
            Response.Redirect("JgMain.aspx?id=10000");
        }
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "ShanChu")
        {
            int ID = Convert.ToInt32(e.CommandArgument);

            string Sql_del = "delete from qp_hr_JiGou_GW where id='" + ID + "'";
            List.ExeSql(Sql_del);
            DataBindToGridview("order by id desc");
        }


    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataControlRowType itemType = e.Row.RowType;
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
            e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";

        }


        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label Lrowid = (Label)e.Row.FindControl("rowid");
            Random g = new Random();
            string rad = g.Next(100000).ToString();

            LinkButton l1 = (LinkButton)e.Row.FindControl("ShanChu");
            l1.Attributes.Add("onclick", "javascript:return confirm('确认删除人员" + e.Row.Cells[0].Text.ToString() + "]吗')");


            LinkButton l2 = (LinkButton)e.Row.FindControl("Xiugai");
            l2.Attributes.Add("onclick", "javascript: window.showModalDialog('JgMain_BZ_update.aspx?tmp=" + rad + "&id=" + Lrowid.Text + "','window','dialogWidth:650px;DialogHeight=410px;status:no;help=no;scroll=no');");


        }
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        DataBindToGridview("order by id asc");
    }
}
